Hotwiring Rails | April 2024
Hi folks, welcome to the first edition of Hotwiring Rails since 2022!
Before we start this month's newsletter, a programming note:
For most of you, it has been a while since you've heard from me. As a reminder, I'm David and I write Hotwiring Rails, a monthly newsletter about Hotwire, Ruby on Rails, and other things I find interesting.
I have been away from blogging and content curation for a while thanks to a few major life milestones. Life has settled now and Hotwiring Rails is back on a monthly schedule, starting right now.
You're receiving this newsletter because you subscribed to Hotwiring Rails at some point in the past. For those of you that subscribed back in 2021 and 2022, I hope you'll find this edition just as valuable. If this newsletter is no longer for you, no hard feelings if you smash that unsubscribe button.
Let's dive in.
David
Articles & Guides
Hotwiring accessible modals in Ruby on Rails by Ayush Newatia
This is a two part series, showing different approaches to building dynamically rendered modals with Stimulus and Turbo with a focus on accessibility. The second article in the series covers creating a custom Turbo Stream action, which is a very powerful tool to have in your Turbo toolbox.
Read the series on Appsignal's blog
How to debug issues with Turbo morphing by Radan Skorić
This is a quick, practical read on how to use the browser's debugging tools to debug issues or trace code paths in Turbo, with a focus on Turbo 8's page morphing. This article is a follow up to two deeper dives into page refreshes and morphing in Turbo 8 by Radan that are also worth a read if you're curious about the internals of how morphing is implemented in Turbo 8.
Turbo Native iOS and Android in 15 minutes by Joe Masilotti
Joe is "The Turbo Native guy" for a reason. This is a very detailed, "step-by-step tutorial to build basic iOS and Android Turbo Native apps from scratch". There is no better resource for getting started building Turbo Native applications with Rails developers than Joe's writing.
Inline edit with Turbo and Stimulus by Keith Schacht
Keith is working on an open source ChatGPT clone. In this 4 minute video he walks through how he built a simple inline edit experience for the project with Turbo and Stimulus. Quick, effective, and clear. This is worth a watch if you've got inline editing on your list of upcoming features.
Read and watch on keithschacht.com
The evolution of Soundcloud's architecture by Stephen Sun
This is the first in a two part series, covering the early evolution of Soundcloud's Rails monolith. No Hotwire content here but I always enjoy reading about how companies navigate the tradeoffs between seizing market opportunity and managing scaling and performance concerns. As is often the case, opportunity came first for Soundcloud because "scaling is a luxury problem".
Read it on fullstackexpress.io
Recent articles from me
I am excited about page refreshing and morphing in Turbo 8, and I have published a few articles exploring how refreshing works:
Turbo 8 morphing refreshes on Rails — This is an overview of what Turbo 8's page refreshes and morphing are and how to integrate them into a Rails app, focusing on replacing a Turbo Stream implementation with a morphing refresh instead.
Turbo 8 refresh sorting — This article is the first in a series. In it we build a page refresh-powered sortable table in a simple Rails app. Along the way we cover a few of the nuances of using page refreshes that can be surprising the first time through.
Turbo 8 search and filter — This article builds on the refresh sorting article to add search and filter to the mix. We still rely on page refreshes to deliver a great user experience while writing view and controller code that will be familiar to any Rails developer, even if they have never used Turbo.
New & interesting Rails-land PRs and releases
Turbo's page refreshes are neat, but they come with some subtleties and are not 100% bug free yet. If you are using page refreshes in production, or planning to soon, it is a very good idea to keep an eye on open issues and PRs in the Turbo repo.
One dangerous bug involves broadcasted refreshes winning out over in-flight, user-initiated page visits, as described here. Sean Doyle, as always, is on top of the issue and a fix lives in this PR.
Another important PR is currently open against the Turbo docs site. The changes in the PR are less interesting than the detailed discussion of visits and what will be treated as a page refresh in Turbo. The behavior is not always intuitive and reading through the full discussion will make it much easier to use page refreshes without spinning in circles wondering why some types of visits are not treated as refreshes.
Paid resources
Last week, Josef Strzibny published the Kamal Handbook, the "missing manual for Kamal". Josef is well-known for Deployment From Scratch and this book entirely focused on Kamal should be worth investing in if you are interested in deploying production applications with Kamal.
Julian Rubisch works on some of the most interesting Hotwire-adjacent projects out there, and his writing is always thoughtful and informative. If you want to dive deeper into Turbo and Stimulus, he publishes weekly challenges on his Patreon, The Hotwire Club, that push you beyond the basics.
A good read about entitlements
I once worked on a product with so many "plans" that we broke our subscription management provider's UI. They never expected someone to have 1,000+ plans and so they didn't have pagination on the index page, and we would smash their database every time we hit the index page (sorry about that, Eric).
We had so many plans because we used them to provide bespoke billing AND entitlements for almost every new deal the sales team closed. In the code, everything was tightly coupled, and life was much harder than it needed to be.
That experience is part of why I really enjoyed You should separate your billing from your entitlements by Arnon Shimoni. Billing is hard. Entitlements are hard. Reading this article might make your life easier some day. H/T to Matt Swanson for sharing this.
A quick Twitter hit
Prabin Poudel shared an approach to account impersonation when you are on token-based authentication.
Until next time
I am rewriting my book on Hotwire and Ruby on Rails. In the past month I have rewritten all of the code, and much of the supporting content. If all goes to plan, I expect to publish the updated version in early May. Anyone who purchased the first version of the book will receive the updated copy for free.
I will see you again in May for the next edition of Hotwiring Rails. If you enjoyed this newsletter, send me a note and let me know, or share it with a friend that might enjoy it too.